#!/usr/bin/python

'''
this is an example of how to access mysql by MySQL standard package
zhaoxp 20151103
'''

import mysql.connector

def query_from_mysql():
	#conn=mysql.connector.connect(user="bugs",password="bugs",database="10.96.20.43",use_unicode=True)
	config = {
		'host':'10.99.201.86',
		'port':3306,
		'database':'test',
		'user':'test',
		'password':'test',
		'charset':'utf8',
		'use_unicode':True,
		'get_warnings':True,
	}
	db=mysql.connector.Connect(**config)
	cursor=db.cursor()
	query_sql='select * from user'
	cursor.execute(query_sql)
	for row in cursor.fetchall():
		print row[0],row[1],row[2]
	
	cursor.close()
	db.close()
	print db
	

if __name__=="__main__":
	print "start to connect mysql"
	query_from_mysql()
	print "-------------end-----------------"